package br.edu.ufcg.p1.barzin.async;

import static br.edu.ufcg.p1.barzin.util.PrefManConstants.TABLET_ID;
import android.os.AsyncTask;
import br.edu.ufcg.p1.barzin.App;
import br.edu.ufcg.p1.barzin.model.ApagarMensagens;
import br.edu.ufcg.p1.barzin.util.HTTPCalls;

public class ApagarMsgsTask extends AsyncTask<Integer, Integer, Boolean> {

	@Override
	protected Boolean doInBackground(Integer... id) {
		Integer idTablet = App.environment().getSharedPreferences()
				.getInt(TABLET_ID, -1);

		ApagarMensagens total = HTTPCalls.precisaApagarMensagem(idTablet);
		if (total == null) {
			return false;
		}
		return App.environment().getDao().apagaMensagens(total);
	}

}
